<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入Vue -->
    <script src="../js/vue.js"></script>
    <style>
        .leftFloat{
            float: left;
            margin-right: 100px;
        }
    </style>
    <title>01_基本列表</title>
</head>
<body>
    
    <!-- 
            v-for 指令：
                1.用于展示列表数据
                2.语法 v-for="(item,index) in xxx"  :key="yyy"
                3.可遍历：数组、对象、字符串（用的少）、指定次数（用的很少）
     -->


    <!-- 容器 -->
    <div id="root">
        <!-- 遍历数组 -->
        <div class="leftFloat">
            <h2>人员列表</h2>
            <ul>
                <li v-for="(p,index) in persons" ::key="p.id">
                    {{p.name}} - {{p.age}} - {{index}}
                </li>
            </ul>
        </div>
        

        <!-- 遍历对象 -->
        <div class="leftFloat">
            <h2>汽车信息</h2>
            <ul>
                <li v-for="(value,k) in car" :key="k">
                    {{k}} - {{value}}
                </li>
            </ul>
        </div>

         <!-- 遍历字符串 -->
         <div class="leftFloat">
            <h2>遍历字符串</h2>
            <ul>
                <li v-for="(char,index) in str" :key="index">
                    {{char}} - {{index}}
                </li>
            </ul>
         </div>

          <!-- 遍历指定次数 -->
          <div class="leftFloat">
            <h2>遍历指定次数</h2>
            <ul>
                <li v-for="(number,index) in 5" :key="index">
                    {{number}} - {{index}}
                </li>
            </ul>
          </div>
    </div>

    <script type="text/javascript">
       Vue.config.productionTip=false; // 阻止 vue 在启动时生成生产提示。

       
       new Vue({
            el:'#root',
            data:{
                persons:[
                    {id:1001,name:'张三',age:18},
                    {id:1002,name:'李四',age:19},
                    {id:1003,name:'王五',age:20},
                ],
                car:{
                    name:'奥迪A9',
                    price : '100万',
                    color:'白色',
                },
                str:'hello,',
            }
        })
 
       
    </script>
</body>
</html>